<?php
/**
 *
 * Sample Application
 *
 * This page shows how to develop a dummy-app. First of all, you need 
 * to include the 'dummy-app.inc', which provides a function, make_app, 
 * to generate the basic SimpleXML structure of the dummy-app for you. 
 *
 * Within the structure, 'nav' refers to your app's navigator, and 
 * 'app' refers to the body of your app. So what you are going to do 
 * are, access the database with '../config.inc', follow the examples 
 * {@link http://www.php.net/manual/en/simplexml.examples-basic.php 
 * here} to manipulate the XML tree, and echo the tree asXML().
 *
 * Tips about the client-side redirection: Where it can be a button, 
 * use a button (with the HTML attribute onclick="load_app('some')"), 
 * rather than a link (with href="javascript:load_app('what')").
 *
 * @link http://www.php.net/manual/en/class.simplexmlelement.php PHP:SimpleXMLElement
 *
 * @author Zhihao Yuan
 * @version 0.1
 * @package dummy-auto
 *
 */

//include('../config.inc');
require('dummy-app.inc');

if (!$_GET['str']) {
$tree = make_app("Sample Application");
$app = $tree->app;
$app->addChild('p', "The main screen");
$app->addChild('table')->addChild('tr');
$app->table->tr->addChild('td', 'This');
$app->table->tr->addChild('td', 'is');
$app->table->addChild('tr');
$app->table->tr[1]->addChild('td', 'a');
$app->table->tr[1]->addChild('td', 'table.');
$app->addChild('form')->addChild('label', "Your name: ");
$app->form->addAttribute('action', 'app/sample.php');
$app->form->addChild('input');
$app->form->input->addAttribute('type', 'text');
$app->form->input->addAttribute('name', 'str');
} else {
$tree = make_app("Sample Application :: Bingo!");
$app = $tree->app;
$app->addChild('h2', "Welcome home, $_GET[str]!");
$app->addChild('a', "Try it again. ");
$app->a['href'] = "javascript:load_app('sample')";
}

echo $tree->asXML();
?>
